<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no"/>
    <script src="../../js/util.js"></script>
    <style type="text/css">
        body, html, #allmap {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            font-family: "微软雅黑";
        }
        button{
            border-radius: 4px;
            outline: 0 none !important;
            height: 30px;
            margin: 5px;;
        }
        .map_option{
            position: relative;
        }
        .content{
            width: 100%;
            height: 100%;
        }

    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=tvlq2AIQlYz6c4noCOtbDTLj"></script>
    <title>设置地图最大、最小级别</title>

</head>
<body>
<div class="content">
    <div class="map_option">
        <button onclick="onConfirm()">确定选择点</button><label id="point_label">sdfsfd</label>
    </div>
    <div id="allmap"></div>

</div>



</body>
</html>
<script type="text/javascript">


    var param=getWindowParam();
    var center=new BMap.Point(111.683204,40.833489);
    if (param&&"center" in param)
    {
        var  centerStr=param.center;
        var point=centerStr.split(",");
        if(point.length==2)
        {
            center =new BMap.Point(point[0],point[1]);
        }
    }
    // 百度地图API功能
    var map = new BMap.Map("allmap"); // 创建Map实例,设置地图允许的最小/大级别
    map.enableScrollWheelZoom(true);
    var opts = {type: BMAP_NAVIGATION_CONTROL_LARGE }
    map.addControl(new BMap.NavigationControl(opts));
    map.centerAndZoom(center, 15);
    var marker = null;
    var label=document.getElementById("point_label")
    updateCenter();
    map.addEventListener("moving", function(){
        updateCenter();               // 将标注添加到地图中
    });

    function updateCenter()
    {
        if (marker!==null)
        {
            map.removeOverlay(marker);
        }
        var center = map.getCenter();
        marker = new BMap.Marker(center);        // 创建标注
        map.addOverlay(marker);
        label.innerHTML=center.lng+","+center.lat;
    }
    function onConfirm() {
        var center=map.getCenter();
        closeSelectWindow(center)
    }
</script>
